package android.apps.bean;

import java.util.Comparator;

/**
 * 按地址排序；
 * Created by lcy on 2015/12/25.
 */
public class ComparatorAddr implements Comparator {

    public int compare(Object arg0, Object arg1) {
        PhotoUpImageItem photo1 = (PhotoUpImageItem) arg0;
        PhotoUpImageItem photo2 = (PhotoUpImageItem) arg1;
        //首先比较地址，如果地址相同，则比较时间；
        if(photo2.getAddress()==null||photo1.getAddress()==null)
            return 0;
        int flag = photo2.getAddress().compareTo(photo1.getAddress());
        if (flag == 0) {
            if (photo2.getDatatime()==null||photo1.getDatatime()==null)
                return 0;
            return photo2.getDatatime().compareTo(photo1.getDatatime());
        } else {
            return flag;
        }
    }
}
